#include "suctionsettingwidget.h"
#include "ui_suctionsettingwidget.h"
#include <QtDebug>
#include <QMessageBox>
suctionSettingWidget::suctionSettingWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::suctionSettingWidget)
{
    ui->setupUi(this);
//    ui->checkBox->setChecked(true);
//    ui->checkBox_2->setChecked(true);
//    ui->lineEdit->setText("4000");

    QList<QCheckBox *> cBoxs = ui->widget->findChildren<QCheckBox *>();
    foreach(QCheckBox *cBox, cBoxs)
    {
        connect(cBox, SIGNAL(clicked(bool)), this, SLOT(changeTableHeaderList(bool)));
//        //默认选中开闭吸阻，并且发送信号
//        emit cBox->clicked(true);
        cBox->setChecked(true);
    }
}

suctionSettingWidget::~suctionSettingWidget()
{
    delete ui;
}

void suctionSettingWidget::changeTableHeaderList(bool flag)
{
//    QCheckBox *cbox = (QCheckBox *)sender();
    tableHeaderStrList.clear();
//    tableHeaderStrList<<"序号";
    QList<QCheckBox *> cBoxs = ui->widget->findChildren<QCheckBox *>();
    foreach(QCheckBox *cBox, cBoxs)
    {
        if(cBox->isChecked())
        {
            tableHeaderStrList<<cBox->text();
        }
    }
    //将table表头发送给测试对象
    tableHeaderStrList.insert(0, "序号");
    emit sendHeaderList(tableHeaderStrList);
}
//保持时间
void suctionSettingWidget::on_lineEdit_editingFinished()
{
//    qDebug()<<"aloha:"<<ui->lineEdit->text().toInt();
    if(ui->lineEdit->text().toInt() > 6000 || ui->lineEdit->text().toInt() < 0)
    {
        QMessageBox::warning(NULL, "提示", "保持时间范围有误");
        ui->lineEdit->clear();
        return;
    }
    emit sendHoldTime(ui->lineEdit->text().toInt());
}
